I originally wrote a function to perform on a project, but now the user wants to have the option to perform this function on either a project or a folder. I have about 200 lines of code that I want to perform in a loop on either the entire parent project or the individual parent folder. Is there an easy way to create a for loop that can use either type? I've tried to set a folder variable to the current Project, thinking that a project is simply a special type of folder. However, I get an error if I try to do this (incorrect arguments for (=) ). Do I need to put the 200 lines of code into a separate function just so I don't have to repeat the same code for current Project and current folder?
Chris Christopher Cote - Mon Jul 15 11:55:52 EDT 2019 |
Re: How to perform same code on either Project or Folder On the one hand you can ask for the type of an item
if (type (i) == "Project" / "Folder") {...
, on the other hand you can get the corresponding folder of a project with the perm Folder folder(string folderName) So you can convert your code to work with folders only and call your function e.g. with the parameter
doSomething (string fName) {
Folder f = folder (fName)
}
Project myP = ...
Folder myF = ...
doSomething(fullName myP)
doSomething(fullName myF)
|